package com.donleo.user.service;

import com.donleo.user.common.CommonResult;
import com.donleo.user.config.FeignClientConfig;
import com.donleo.user.model.Word;
import com.donleo.user.service.impl.WordServiceFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

/**
 * 声明式服务调用配置
 * .@FeignClient 指定服务
 * value            服务名
 * fallbackFactory  调用失败，服务降级返回结果
 * configuration    自定义配置
 *
 * @author liangd
 * @since 2021-01-12 16:18
 */
@FeignClient(value = "word-app", fallbackFactory = WordServiceFallbackFactory.class, configuration = FeignClientConfig.class)
public interface WordService {
    /**
     * 查询所有
     */
    @GetMapping("/word/findAll")
    CommonResult feignFindAllWord();

    /**
     * 单个查询
     */
    @GetMapping("/word/findById2")
    CommonResult feignFindWordById(@RequestParam("id") Integer id);

    /**
     * 新增
     */
    @PostMapping("/word/create")
    CommonResult feignCreateWord(@RequestBody Word word);

    /**
     * 修改
     */
    @PutMapping("/word/update")
    CommonResult feignUpdateWord(@RequestBody Word word);

    /**
     * 删除
     */
    @DeleteMapping("/word/delete")
    CommonResult feignDeleteWordById(@RequestParam("id") Integer id);
}
